bitkeeper revision 1.990.2.9 (40d6f5f8xz_AYQRSIovsE9CVdGY9aQ)
authormjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Mon, 21 Jun 2004 14:51:36 +0000 (14:51 +0000)
committermjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Mon, 21 Jun 2004 14:51:36 +0000 (14:51 +0000)
Remove consoles when domains die.
Some other small fixes.

tools/xenmgr/lib/EventServer.py
tools/xenmgr/lib/XendConsole.py
tools/xenmgr/lib/server/SrvConsoleServer.py
tools/xenmgr/lib/server/controller.py
tools/xenmgr/lib/xm/main.py

index 9749e119fbaf0b8dc8ca7427e66c481cc26c14b1..6fae2b9ccfdee7c6e901a4ecdce0a26f3ca2c605 100644 (file)
@@ -85,7 +85,8 @@ class EventServer:
         hl = self.handlers.get(event)
         if hl is None:
             return
-        hl.remove(handler)
+        if handler in hl:
+            hl.remove(handler)
 
     def inject(self, event, val):
         """Inject an event. Handlers for it are called if runing, otherwise
index 041e6c4d44f6835f85cf2be3044e3c1b5638fe76..19ad7eeae35db070aa50d58438fb3598c788c19c 100644 (file)
@@ -104,8 +104,10 @@ class XendConsole:
                 self._delete_console(c.id)
 
     def onDomainDied(self, event, val):
+        print 'onDomainDied', "dom=", dom,
         dom = int(val)
         for c in self.consoles():
+            print 'onDomainDied', "dom=", dom, "dom1=", c.dom1, "dom2=", c.dom2
             if (c.dom1 == dom) or (c.dom2 == dom):
                 self._delete_console(c.id)
 
index c33ddbd8326e6acf74f70366909939734f1afeef..6059ef2ebf015e291374f511987fd6c3d1df5c37 100644 (file)
@@ -291,6 +291,12 @@ class EventProtocol(protocol.Protocol):
             else:
                 self.send_error()
 
+    def loseConnection(self):
+        if self.transport:
+            self.transport.loseConnection()
+        if self.connected:
+            reactor.callLater(0, self.connectionLost)
+
     def connectionLost(self, reason=None):
         self.unsubscribe()
 
@@ -663,7 +669,7 @@ class Daemon:
         """
         dom = int(id)
         if dom <= 0: return 0 
-        return xc.domain_destroy(dom=dom, force=0)
+        return xc.domain_destroy(dom=dom, force=force)
     
 
 def instance():
index 793ac859687ec871f60f3c525d2c8df9f205b61a..23b0f7fde1e722fd973564d0e27634f79b029dd8 100755 (executable)
@@ -37,9 +37,7 @@ class CtrlMsgRcvr:
     
     def registerChannel(self):
         self.channel = self.channelFactory.domChannel(self.dom)
-        #print 'registerChannel> channel=', self.channel, self
         self.idx = self.channel.getIndex()
-        #print 'registerChannel> idx=', self.idx
         if self.majorTypes:
             self.channel.registerDevice(self.majorTypes, self)
         
@@ -90,7 +88,7 @@ class ControllerFactory(CtrlMsgRcvr):
         return None
 
     def delInstance(self, instance):
-        if instance in self.instances:
+        if instance.idx in self.instances:
             del self.instances[instance.idx]
 
     def createInstance(self, dom):
index ebd9411428a8f0d3811a755462b21a7394af5bb6..32a7be879b58731b47130f4410c170e5e861f244 100644 (file)
@@ -76,6 +76,7 @@ class Xm:
         """List domains."""
         if help: self.help('xm_' + args[0], args); return
         doms = server.xend_domains()
+        doms.sort()
         print 'Dom  Name             Mem(MB)  CPU  State  Time(s)'
         for dom in doms:
             info = server.xend_domain(dom)
@@ -86,7 +87,7 @@ class Xm:
             d['cpu'] = int(sxp.child_value(info, 'cpu', '0'))
             d['state'] = sxp.child_value(info, 'state', '??')
             d['cpu_time'] = float(sxp.child_value(info, 'cpu_time', '0'))
-            print ("%(dom)-4d %(name)-16s %(mem)4d     %(cpu)3d %(state)5s %(cpu_time)10.2f" % d)
+            print ("%(dom)-4d %(name)-16s %(mem)7d  %(cpu)3d  %(state)5s  %(cpu_time)7.1f" % d)
 
     def xm_domain(self, help, args):
         """Get information about a domain."""
@@ -144,32 +145,6 @@ class Xm:
         v = map(int, args[1:3])
         server.xend_domain_pincpu(*v)
 
-##     def xm_vif_stats(self, help, args):
-##         """Get stats for a virtual interface."""
-##         if help:
-##             print args[0], 'DOM VIF'
-##             print '\nGet stats for interface VIF on domain DOM.'
-##             return
-##         if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
-##         v = map(int, args[1:3])
-##         print server.xend_domain_vif_stats(*v)
-
-##     def xm_vif_rate(self, help, args):
-##         """Set or get vif rate params."""
-##         if help:
-##             print args[0], "DOM VIF [BYTES USECS]"
-##             print '\nSet or get rate controls for interface VIF on domain DOM.'
-##             return
-##         n = len(args)
-##         if n == 3:
-##             v = map(int, args[1:n])
-##             print server.xend_domain_vif_scheduler_get(*v)
-##         elif n == 5:
-##             v = map(int, args[1:n])
-##             server.xend_domain_vif_scheduler_set(*v)
-##         else:
-##             self.err("%s: Invalid argument(s)" % args[0])
-
     def xm_bvt(self, help, args):
         """Set BVT scheduler parameters."""
         if help: